package com.plian.system.dao.sys.orgzation;

import com.plian.Tools.pagedata.PageData;
import com.plian.system.dao.DaoSupport;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * 工作流用户组与用户关联dao
 */
@Component
public class UserGroupRelationDao {
    @Resource(name="daoSupport")
    private DaoSupport dao;

    public void insert(PageData pd) throws Exception {
        dao.save("SysWfGroupUserRelationMapper.insert",pd);
    }

    public void deleteByGroupId(PageData pd) throws Exception {
        dao.delete("SysWfGroupUserRelationMapper.deleteByGroupId",pd);
    }
    public void deleteByUserId(String  uerId) throws Exception {
        dao.delete("SysWfGroupUserRelationMapper.deleteByUserId",uerId);
    }

    /**
     * 根据用户id加组织id删除
     * @param pd
     * @throws Exception
     */
    public void deleteByUserIdAndOrgId(PageData pd) throws Exception {
        dao.delete("SysWfGroupUserRelationMapper.deleteByUserIdAndOrgId",pd);
    }

    public void insertBatch(PageData pd) throws Exception {
        dao.save("SysWfGroupUserRelationMapper.insertBatch",pd);
    }

    public List<String> selectUserIdListByGroupId(PageData pd) throws Exception {
        return (List<String>)dao.findForList("SysWfGroupUserRelationMapper.selectUserIdListByGroupId",pd);
    }
    public List<PageData> getListByUserId(String userId) throws Exception {
        return (List<PageData>)dao.findForList("SysWfGroupUserRelationMapper.getListByUserId",userId);
    }

    public List<PageData> selectByOrganizationId(PageData pd) throws Exception {
        return (List<PageData>)dao.findForList("SysWfGroupUserRelationMapper.selectByOrganizationId",pd);
    }

    public List<PageData> getGroupIdListByUserIdAndOrganizationId(PageData pd) throws Exception {
        return (List<PageData>)dao.findForList("SysWfGroupUserRelationMapper.getGroupIdListByUserIdAndOrganizationId",pd);
    }

    public List<PageData> getGroupIdListByUserId(PageData pageData) throws Exception {
        return (List<PageData>)dao.findForList("SysWfGroupUserRelationMapper.getGroupIdListByUserId",pageData);
    }
}
